home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / BUS / TMCM Software and Labs.sit / Software for TMCM 7_95 / Files for Lab 11 / Symmetry Subs < prev    next >
Text File  |  1993-10-31  |  4KB  |  226 lines

  1. { This file defines subroutines for drawing "symmetric"
  2.   pictures.  The subroutines
  3.  
  4.            multiForward(dist)
  5.            multiBack(dist)
  6.            multiArc(radius,degrees)
  7.            multiCircle(radius)
  8.            multiMove(dx,dy)
  9.            multiMoveTo(x,y)
  10.  
  11.   can be used as replacements for the usual subroutines
  12.   forward, back, arc, circle, move and moveTo.   Instead of
  13.   drawing a single line or arc, these "mulit" subroutines draw
  14.   eight things: the ususal one and all its horizontal and
  15.   vertical reflections.  To make a symmetric picture, put
  16.   your program at the end of this file and use these
  17.   subroutines in place of the usual ones.
  18.  
  19.   NOTE:  You don't have to read the definitions of these
  20.          subroutines or understand how they work in order
  21.          to use them.  Just use them as "black boxes."
  22. }
  23.  
  24.  
  25. {--------------- Definitions of Subroutines ----------------}
  26.  
  27. SUB multiforward(d)
  28.  
  29.    IF isDrawing = 0 THEN
  30.       forward(d)
  31.       RETURN
  32.    END IF
  33.  
  34.    DECLARE save_heading, save_x, save_y
  35.    save_heading := heading
  36.    save_x := xcoord
  37.    save_y := ycoord
  38.    
  39.    penUp
  40.    moveTo(-save_y, save_x)
  41.    penDown
  42.    face(90 + save_heading)
  43.    forward(d)
  44.  
  45.    penUp
  46.    moveTo(save_y, -save_x)
  47.    penDown
  48.    face(-90 + save_heading)
  49.    forward(d)
  50.  
  51.    penUp
  52.    moveTo(-save_y, -save_x)
  53.    penDown
  54.    face(-90 - save_heading)
  55.    forward(d)   
  56.  
  57.    penUp
  58.    moveTo(save_y,save_x)
  59.    penDown
  60.    face(90 - save_heading)
  61.    forward(d)
  62.  
  63.    penUp
  64.    moveTo(save_x, -save_y)
  65.    penDown
  66.    face(-save_heading)
  67.    forward(d)
  68.  
  69.    penUp
  70.    moveTo(-save_x, save_y)
  71.    penDown
  72.    face(180 - save_heading)
  73.    forward(d)
  74.  
  75.    penUp
  76.    moveTo(-save_x, -save_y)
  77.    penDown
  78.    face(180 + save_heading)
  79.    forward(d)   
  80.  
  81.    penUp
  82.    moveTo(save_x,save_y)
  83.    penDown
  84.    face(save_heading)
  85.    forward(d)
  86.  
  87. END SUB
  88.  
  89.  
  90. SUB multiarc(r,d)
  91.  
  92.    IF isDrawing = 0 THEN
  93.       arc(r,d)
  94.       RETURN
  95.    END IF
  96.  
  97.    DECLARE save_heading, save_x, save_y
  98.    save_heading := heading
  99.    save_x := xcoord
  100.    save_y := ycoord
  101.    
  102.    penUp
  103.    moveTo(-save_y, save_x)
  104.    penDown
  105.    face(90 + save_heading)
  106.    arc(r,d)
  107.  
  108.    penUp
  109.    moveTo(save_y, -save_x)
  110.    penDown
  111.    face(-90 + save_heading)
  112.    arc(r,d)
  113.  
  114.    penUp
  115.    moveTo(-save_y, -save_x)
  116.    penDown
  117.    face(-90 - save_heading)
  118.    arc(-r,d)   
  119.  
  120.    penUp
  121.    moveTo(save_y,save_x)
  122.    penDown
  123.    face(90 - save_heading)
  124.    arc(-r,d)
  125.  
  126.    penUp
  127.    moveTo(save_x, -save_y)
  128.    penDown
  129.    face(-save_heading)
  130.    arc(-r,d)
  131.  
  132.    penUp
  133.    moveTo(-save_x, save_y)
  134.    penDown
  135.    face(180 - save_heading)
  136.    arc(-r,d)
  137.  
  138.    penUp
  139.    moveTo(-save_x, -save_y)
  140.    penDown
  141.    face(180 + save_heading)
  142.    arc(r,d)   
  143.  
  144.    penUp
  145.    moveTo(save_x,save_y)
  146.    penDown
  147.    face(save_heading)
  148.    arc(r,d)
  149.  
  150. END SUB
  151.  
  152.  
  153. SUB multiMoveTo(x,y)
  154.  
  155.    IF isDrawing = 0 THEN
  156.       MoveTo(x,y)
  157.       RETURN
  158.    END IF
  159.  
  160.    DECLARE save_heading, save_x, save_y
  161.    save_heading := heading
  162.    save_x := xcoord
  163.    save_y := ycoord
  164.    
  165.    penUp
  166.    moveTo(-save_y, save_x)
  167.    penDown
  168.    moveTo(-y,x)
  169.  
  170.    penUp
  171.    moveTo(save_y, -save_x)
  172.    penDown
  173.    moveTo(y,-x)
  174.  
  175.    penUp
  176.    moveTo(-save_y, -save_x)
  177.    penDown
  178.    moveTo(-y,-x)   
  179.  
  180.    penUp
  181.    moveTo(save_y,save_x)
  182.    penDown
  183.    moveTo(y,x)
  184.  
  185.    penUp
  186.    moveTo(save_x, -save_y)
  187.    penDown
  188.    moveTo(x,-y)
  189.  
  190.    penUp
  191.    moveTo(-save_x, save_y)
  192.    penDown
  193.    moveTo(-x,y)
  194.  
  195.    penUp
  196.    moveTo(-save_x, -save_y)
  197.    penDown
  198.    moveTo(-x,-y)   
  199.  
  200.    penUp
  201.    moveTo(save_x,save_y)
  202.    penDown
  203.    moveTo(x,y)
  204.  
  205. END SUB
  206.  
  207.  
  208. SUB multiback(d)
  209.    multiforward(-d)
  210. END SUB
  211.  
  212.  
  213. SUB multicircle(r)
  214.    multiarc(r,360)
  215. END SUB
  216.  
  217.  
  218. SUB multiMove(dx,dy)
  219.    multiMoveTo(xcoord + dx, xcoord + dy)
  220. END SUB
  221.  
  222.  
  223. {------------ End of Subroutine Definitions ------------------}
  224.  
  225.  
  226.